<?php

$app->path('posts', function ($request) use ($app) {
    // Integer path segment, like 'posts/42'
    $app->param('int', function ($request, $id) use ($app) {
        $app->get(function ($request) use ($id) {
            // View post
            return 'view_' . $id;
        });
        $app->put(function ($request) use ($id) {
            // Update resource
            $post->data($request->post());
            $post->save();
            return 'update_' . $id;
        });
        $app->delete(function ($request) use ($id) {
            // Delete resource
            $post->delete();
            return 'delete_' . $id;
        });
    });
    // All printable characters except space
    $app->param('ctype_graph', function ($request, $slug) use ($app) {
        return $slug; // 'my-post-title'
    });
});
